// 用户相关api
import request from '../utils/http'

// 登录
export function login(data) {
  return request({
    url: '/users/login',
    method: 'post',
    data
  })
}

// 退出
export function logout() {
  return request({
    url: '/users/logout',
    method: 'get'
  })
}

// 获取用户信息
export function getUserInfo(params) {
  return request({
    url: '/users',
    method: 'get',
    params
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/users/add',
    method: 'post',
    data
  });
}


// 编辑用户
export function updateUser(id, data) {
  return request({
    url: `/users/${id}`,
    method: 'put',
    data
  });
}

// 重置用户密码
export function resetUserPassword(user_id, password) {
  return request({
    url: `/users/resetPassword/${user_id}`,
    method: 'put',
    data: {
      string: password
    }
  });
}

// 删除用户
export async function deleteUser(user_id) {
  return request({
    url: '/users/delete/' + user_id,
    method: 'delete'
  })
}

// 修改密码
export function updatePassword(data) {
  return request({
    url: `/users/updatePassword/${user_id}`,
    method: 'put',
    data
  })
}